<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Hello World!</title>


    <!-- Insert this line above script imports  -->
    <script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>

    <!-- normal script imports etc  -->
    <script src="js/jquery-3.3.1.min.js"></script>  
    
    <script src='js/sql.js'></script>

    <!-- Insert this line after script imports -->
    <script>if (window.module) module = window.module;</script>

    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">


  </head>
  <body>

  
    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark static-top">
      <div class="container">
        <a class="navbar-brand" href="#">Start Bootstrap</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
          <ul class="navbar-nav ml-auto">
            <li class="nav-item active">
              <a class="nav-link" href="#">Home
                <span class="sr-only">(current)</span>
              </a>
            </li>
            <li class="nav-item">
              <a  class="nav-link" href="in.html">IN</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="in2.html">IN2</a>
            </li>
            <li class="nav-item">
              <a id="change" class="nav-link" href="#">change</a>
            </li>
            <li class="nav-item">
              <a id="Qbtn" class="nav-link" href="#">Quitter</a>
            </li>
          </ul>
        </div>
      </div>
    </nav>

    <!-- Page Content -->
    <div class="container">
      <div class="row">
        <div class="col-lg-12 text-center">
          <h1 class="mt-5">A Bootstrap 4 Starter Template</h1>
          <p class="lead">Complete with pre-defined file paths and responsive navigation!</p>
          <ul class="list-unstyled">
            <li>Bootstrap 4.1.3</li>
            <li><div id="resul">aaa</div></li>
          </ul>
        </div>
      </div>
    </div>

    


    <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script>
      // You can also require other files to run in this process
      require('./js/renderer.js');

        document.getElementById('Qbtn').onclick = function(event) {
              const remote = require('electron').remote // chargement de l'api remote
              var window = remote.getCurrentWindow() // on récupère la fenetre courante
              window.close() // on ferme la fenetre
            }


        $("#change").click( function() {   $("#resul").html("ekekek"); }  );

       
        /* ###### pour lire la table dans la base ####### */
        var fs = require("fs"); 
        var SQL = require("./js/sql.js");  
        
       
        var filebuffer = fs.readFileSync('bd/mybd.sqlite'); 


        // Load the db
        var db = new SQL.Database(filebuffer);

 

        var stmt = db.prepare("SELECT col1,col2 FROM test");               
        
        var acc = "";
        
        while(stmt.step()) {  
          

          var row = stmt.getAsObject();  
          acc += row.col1+" "+row.col2+"<br>";
        }

          $("#resul").html(acc);


    </script>
  </body>
</html>
